#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

#include "drm_drv/drm_plane_drv.h"
#include "v4l2_drv/v4l2_capture.h"
#include "drm_pipe/pipe_stream.h"
#include "drm_pipe/pipe_merge.h"
#include "display_mode.h"
#include "net_protocol/TCPServer.h"

using namespace std;

Capture cap[10];
struct plane_arg plane[10];
Pipe_Stream pipe_s[10];
Pipe_Merge pipe_merge;



int main(int argc, char **argv)
{
    setvbuf(stdout,NULL,_IOLBF,0);

    drm_print();
    drm_crtc_id_init();
//设置drm分层的透明度属性。
//    drm_alpha_init();

//init video capture thread
    for(int i=0;i<8;i++){
        cap[i].initCapture(i,V4L2_PIX_FMT_NV12);
    }
//init tcp thread
    TCPServer tcp;
    tcp.setup(PORT);//设置服务器端口
    thread SocketThread(&TCPServer::receive, &tcp);

//init default display
    printf("screen1x2x3x4x5x6");
    pipe_stop_all(pipe_s);
    screen_mode(plane,10,screen1x2x3x4x5x6);
    for(int i=0;i<6;i++)
        pipe_s[i].start(&cap[i],&plane[i],nv12_rgb);
//    pipe_s[5].start(&cap[5],&plane[5],nv12_rgb);

    while (true) {
        sleep(5);
    }
    return 0;
}
